package thread;

public class demo17 {

    public static Object object1 = new Object();
    public static Object object2 = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            synchronized (object1){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (object2) {
                    System.out.println("t1锁操作完成");
                };
            };


        });
        Thread t2 = new Thread(()->{
            synchronized (object2){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (object1) {
                    System.out.println("t2锁操作完成");
                };
            };

        });
        t1.start();
        t2.start();

    }
}
